//#version 330 core
//layout (triangles) in;
//layout (triangle_strip, max_vertices = 3) out;


//in vec2 qt_TexCoord0[];
//in vec3 modelvertex[];

//out vec2 TexCoords;
//out vec3 normal;

//vec3 GetNormalModel()
//{
//   vec3 a = vec3(modelvertex[2]) - vec3(modelvertex[1]);
//   vec3 b = vec3(modelvertex[0]) - vec3(modelvertex[1]);
//   return normalize(cross(a, b));
//}

//vec3 GetNormalDev()
//{
//   vec3 a = vec3(gl_in[0].gl_Position) - vec3(gl_in[1].gl_Position);
//   vec3 b = vec3(gl_in[2].gl_Position) - vec3(gl_in[1].gl_Position);
//   return normalize(cross(a, b));
//}
//void main() {
//    normal = GetNormalModel();
//    gl_Position = gl_in[0].gl_Position;
//    TexCoords = qt_TexCoord0[0];
//    EmitVertex();
//    gl_Position = gl_in[1].gl_Position;
//    TexCoords = qt_TexCoord0[1];
//    EmitVertex();
//    gl_Position = gl_in[2].gl_Position;
//    TexCoords = qt_TexCoord0[2];
//    EmitVertex();
//    EndPrimitive();

//}
#version 330 core
layout (triangles) in;
layout (line_strip, max_vertices = 6) out;


in vec2 qt_TexCoord0[];
in vec3 modelvertex[];

out vec2 TexCoords;
out vec3 normal;

vec3 GetNormalModel()
{
   vec3 a = vec3(modelvertex[2]) - vec3(modelvertex[1]);
   vec3 b = vec3(modelvertex[0]) - vec3(modelvertex[1]);
   return normalize(cross(a, b));
}

vec3 GetNormalDev()
{
   vec3 a = vec3(gl_in[0].gl_Position) - vec3(gl_in[1].gl_Position);
   vec3 b = vec3(gl_in[2].gl_Position) - vec3(gl_in[1].gl_Position);
   return normalize(cross(a, b));
}
void main() {
    normal = GetNormalModel();

    vec3 normaldev=GetNormalDev();

    gl_Position = (gl_in[0].gl_Position+gl_in[1].gl_Position+gl_in[2].gl_Position)/3;
   EmitVertex();
   gl_Position = gl_Position + vec4(normaldev, 0) * 0.1f;
   EmitVertex();
   EndPrimitive();

}
